package com.activity.servcice;

import com.activity.bean.Seckill;
import com.activity.bean.dto.Exposer;
import com.activity.bean.dto.SeckillExecution;
import com.activity.exception.RepeatKillException;
import com.activity.exception.SeckillCloseException;
import com.activity.exception.SeckillException;

import java.util.List;

/**
 * Created by wangzhanjin on 2017/12/26.
 */
public interface SeckillService {

    Seckill queryById(long seckillId);

    /**
     * 查询所有秒杀记录
     */
    List<Seckill> queryAll();

    /**
     * 秒杀开启时，输出秒杀接口地址
     * 否者输出系统时间和秒杀时间
     * @param seckillId
     */
    Exposer exportSeckillUrl(long seckillId);

    /**
     * 执行秒杀操作
     * 和内部md5进行对比
     * @param seckillId
     * @param userPhone
     * @param md5
     * 抛出SeckillException和后面的两个不一样的，用于区分
     */
    SeckillExecution excuteSeckill(long seckillId, long userPhone, String md5)
            throws SeckillException,RepeatKillException,SeckillCloseException;

    SeckillExecution excuteSeckillProcedure(long seckillId, long userPhone, String md5)
            throws SeckillException,RepeatKillException,SeckillCloseException;
}
